<?php

class Frontend_Filter_Characters implements Zend_Filter_Interface
{

	protected $_allowedChars = ' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
	
    public function __construct($allowChars = false, $reset = false)
    {
		
    	if( $reset ){
    		
			if( is_string($allowChars) ){
    		
    			$this->_allowedChars = $allowChars;
    		
    		}  		
    		
    	}else{
    		
    		if( is_string($allowChars) ){
    			
    			$this->_allowedChars .= $allowChars;
    			
    		}    		
    		
    	}
    	
    }

    public function filter($value)
    {
		
    	$allowArray = str_split( $this->_allowedChars );
    	
    	$againstArray = str_split( (string) $value );
    	
    	$filterValue = '';
    	
    	foreach( $againstArray as $char){
    		
    		if( in_array($char, $allowArray) ){
    			
    			$filterValue .= $char;
    			
    		}
    		
    	}
    	
    	return $filterValue;
    }
}
